package com.tencent.qf.activity.special.area.service.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tencent.qf.activity.special.area.service.dal.DO.TsGiftCouponOrderRecord;
import com.tencent.qf.activity.special.area.service.dal.mapper.TsGiftCouponOrderRecordMapper;
import com.tencent.qf.activity.special.area.service.service.TsGiftCouponOrderRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
* @author p_haojiawu
* @description 针对表【ts_gift_coupon_order_record(礼金核销订单明细表)】的数据库操作Service实现
* @createDate 2023-08-18 14:42:10
*/
@Service
public class TsGiftCouponOrderRecordServiceImpl extends ServiceImpl<TsGiftCouponOrderRecordMapper, TsGiftCouponOrderRecord>
    implements TsGiftCouponOrderRecordService {

    @Resource
    private TsGiftCouponOrderRecordMapper tsGiftCouponOrderRecordMapper;


    @Override
    public List<TsGiftCouponOrderRecord> getCouponUsed(String uid, List<String> giftKey) {
        QueryWrapper<TsGiftCouponOrderRecord> query = new QueryWrapper<>();
        query.eq("buyerinfo_cpsuid", uid)
                .in("gift_key", giftKey)
                .notIn("order_status", Arrays.asList("CANCEL", "NOT_VALID"))
                .isNull("deleted_at");

        return tsGiftCouponOrderRecordMapper.selectList(query);
    }
}




